﻿//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
// Exo² - Tools - Studio/ExefBuilderModule
// Copyright (C) 2007-2008 Samuel Lacroix and Raphaël Legouge
//
// Distributed under GNU General Public License
// See the License folder for details
// http://www.codeplex.com/exo2 (eng)
//-----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ExefBuilderModule
{
        public partial class CreatePhysiology : Form
        {
                public CreatePhysiology()
                {
                        InitializeComponent();
                }
                
                public void ResetForm()
                {
                        this.textBox1.Text = "";
                        this.textBox2.Text = "";
                        this.textBox3.Text = "";
                        this.textBox4.Text = "";
                        this.checkBox1.Checked = true;
                        this.radioButton1.Checked = true;
                        this.radioButton2.Checked = false;
                }

                private void button2_Click(object sender, EventArgs e)
                {
                        if (this.textBox1.TextLength == 0)
                        {
                                MessageBox.Show("you have to write a physiology name.");
                                return;
                        }
                        if (this.textBox2.TextLength == 0)
                        {
                                MessageBox.Show("you have to choose an input x file.");
                                return;
                        }
                        try
                        {
                                Convert.ToDouble(this.textBox3.Text);
                        }
                        catch (FormatException E)
                        {
                                MessageBox.Show("you have to write a number.");
                                return;
                        }
                        if (this.checkBox1.Checked && this.textBox4.TextLength == 0)
                        {
                                MessageBox.Show("you have to choose an output x file.");
                                return;
                        }
                              
                        this.DialogResult = DialogResult.OK;
                }

                private void button1_Click(object sender, EventArgs e)
                {
                        this.DialogResult = DialogResult.Cancel;
                }
                
                public string getPhysiologyName()
                {
                        return this.textBox1.Text;
                }
                
                public string getSourceXFileName()
                {
                        return this.textBox2.Text;
                }
                
                public double getMassOrDensity()
                {
                        return Convert.ToDouble(this.textBox3.Text);
                }
                
                public Boolean getUseMass()
                {
                        return this.radioButton1.Checked;
                }
                
                public Boolean getSaveTargetXFile()
                {
                        return this.checkBox1.Checked;
                }
                
                public string getTargetXFileName()
                {
                        return this.textBox4.Text;
                }

                private void button3_Click(object sender, EventArgs e)
                {
                        if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                                this.textBox2.Text = this.openFileDialog1.FileName;
                        }
                }

                private void button4_Click(object sender, EventArgs e)
                {
                        if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                                this.textBox4.Text = this.saveFileDialog1.FileName;
                        }
                }

                private void checkBox1_CheckedChanged(object sender, EventArgs e)
                {
                        CheckBox checkBox = (CheckBox)sender;
                        this.button4.Enabled = checkBox.Checked;
                        this.textBox4.Enabled = checkBox.Checked;
                }
        }
}
